using System;
using System.Collections.Generic;
using System.Text;
using IGCal.GA;
using IGCal.DB;
using IGCal.Serialization;

namespace Calcio
{
  /// <summary>
  /// Machine settings (sempre su hard disk - all users - in XML)
  /// </summary>
  public class MachineSettings : IReportOutputTypeSetting, IConnectionSetting
  {

    #region IReportOutputTypeSetting Members

    private ReportOutputType _ReportOutputType = ReportOutputType.MSOffice;

    public ReportOutputType ReportOutputType
    {
      get
      {
        return _ReportOutputType;
      }
      set
      {
        _ReportOutputType = value;
      }
    }

    #endregion

    private string _ModelloXlsDistinta = "";
     

    public string ModelloXlsDistinta
    {
      get
      {

        return _ModelloXlsDistinta;
      }
      set
      {
        _ModelloXlsDistinta = value;
      }
    }


    #region IConnectionProperties Members

    private string _ConnectionString = null;
    private ProviderType _ProviderType = ProviderType.OleDb;

    public string ConnectionString
    {
      get
      {
        return _ConnectionString;
      }
      set
      {
        _ConnectionString = value;
      }
    }

    public IGCal.DB.ProviderType ProviderType
    {
      get
      {
        return _ProviderType;
      }
      set
      {
        _ProviderType = value;
      }
    }

    #endregion


    #region Serializzazione / Deserializzazione

    public void Serialize()
    {
#warning Tornare un errore eventualmente "ridefinito" (di solito non posso accedere in scrittura alla cartella)
      Globals.FileSystemSettingsSerializer.Write(false, "Settings", "MachineSettings", this);
    }

    public static MachineSettings Deserialize()
    {
      object o = null;

      try
      {
        o = Globals.FileSystemSettingsSerializer.Read(false, "Settings", "MachineSettings", typeof(MachineSettings));
      }
      catch { }
      
      if (o == null)
        return new MachineSettings();
      else
        return (MachineSettings)o;
    }

    #endregion

  }
}
